package com.dfec.water.dao;

import com.dfec.framework.mybatis.core.mapper.BaseMapperX;
import com.dfec.framework.mybatis.core.page.PageParam;
import com.dfec.framework.mybatis.core.page.PageUtils;
import com.dfec.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.dfec.water.entity.YdbApplyInfoEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;

/**
 * 淤地坝事件上报信息Dao接口
 *
 * @author df
 * @date Thu Jan 09 11:17:02 CST 2025
 */
@Mapper
public interface YdbApplyInfoDao extends BaseMapperX<YdbApplyInfoEntity> {

    /**
     * description:分页查询
     *
     * @param pageParam 分页参数
     * @return
     * @author trg
     * @date 2023/6/27 15:56
     */
    default PageUtils selectPage(PageParam<YdbApplyInfoEntity> pageParam) {
            YdbApplyInfoEntity entity = pageParam.getEntity() == null ? new YdbApplyInfoEntity() :pageParam.getEntity();
        return this.selectPage(pageParam, dealParams(entity));
    }


    /**
     * 不带分页查询
     * @param ydbApplyInfoEntity
     * @return
     */
    default  List<YdbApplyInfoEntity> selectAll(YdbApplyInfoEntity ydbApplyInfoEntity){
        return this.selectList(dealParams(ydbApplyInfoEntity));
    }

    /**
    * description:查询条件拼接
    *
    * @param entity 参数
    * @return
    * @author trg
    * @date 2023/6/27 15:56
    */
    public default LambdaQueryWrapperX<YdbApplyInfoEntity> dealParams(YdbApplyInfoEntity entity){
        return new LambdaQueryWrapperX<YdbApplyInfoEntity>()
                            .eqIfPresent(YdbApplyInfoEntity::getId, entity.getId())
                            .eqIfPresent(YdbApplyInfoEntity::getAreaId, entity.getAreaId())
                            .eqIfPresent(YdbApplyInfoEntity::getApplyUserId, entity.getApplyUserId())
                            .eqIfPresent(YdbApplyInfoEntity::getApplyContent, entity.getApplyContent())
                            .eqIfPresent(YdbApplyInfoEntity::getStatus, entity.getStatus())
                            .eqIfPresent(YdbApplyInfoEntity::getApplyTime, entity.getApplyTime())
                            .eqIfPresent(YdbApplyInfoEntity::getCreateUser, entity.getCreateUser())
                            .eqIfPresent(YdbApplyInfoEntity::getCreateTime, entity.getCreateTime())
                            .eqIfPresent(YdbApplyInfoEntity::getUpdateUser, entity.getUpdateUser())
                            .eqIfPresent(YdbApplyInfoEntity::getUpdateTime, entity.getUpdateTime())
        ;
    }



}
